package com.xuyunceng.xinlin.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Log {

	@Pointcut("execution(* com.xuyunceng.xinlin.service..*.*(..))")
	private void any() {}// 定义一个切入点

	@Before("any()")
	public void doAccessCheck() {
		System.out.println("---前置通知---");
	}

	@AfterReturning("any()")
	public void doAfter() {
		System.out.println("---后置通知---");
	}

	@After("any()")
	public void after() {
		System.out.println("---返回后通知---");
	}

	@AfterThrowing("any()")
	public void doAfterThrow() {
		System.out.println("---报错通知---");
	}

	@Around("any()")
	public Object doBasicProfiling(ProceedingJoinPoint pj) throws Throwable {
		System.out.println("---开始环绕---");
		Object object = pj.proceed();// 执行该方法
		System.out.println("---环绕结束---");
		return object;
	}
	
}
